<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <link rel="stylesheet" href="../libs/layui/css/layui.css" />
  <link rel="stylesheet" href="../css/reset.css" />
  <link rel="stylesheet" href="../css/center.css" />
  <title>判断</title>
</head>

<body>
  <div style="padding: 60px" id="maniBody">
    <div id="view"></div>
  </div>
</body>
<script id="demo" type="text/html">
    <span class="title">【{{ d.topTitle }}】</span>
    <div class="subject">{{ d.index + 1}}、{{- d.title }}</div>
    <form class="layui-form" action="" lay-filter="form">
      <div class="layui-form-item">
        <div class="layui-input-block">
          <input
            type="radio"
            name="current"
            value="A"
            title="正确"
            lay-filter="current"
          />
          <input
            type="radio"
            name="current"
            value="B"
            title="错误"
            lay-filter="current"
          />
        </div>
      </div>
    </form>
  </script>
<script src="../libs/jquery.min.js"></script>
<script src="../libs/layui/layui.js"></script>

<script>
  function changeSize(type) {
    if (type == "small") {
      $(".title").css("fontSize", "12px");
      $(".subject").css("fontSize", "16px");
      $(".layui-form-radio *").css("fontSize", "14px");
    }
    if (type == "normal") {
      $(".title").css("fontSize", "16px");
      $(".subject").css("fontSize", "20px");
      $(".layui-form-radio *").css("fontSize", "18px");
    }
    if (type == "larger") {
      $(".title").css("fontSize", "20px");
      $(".subject").css("fontSize", "24px");
      $(".layui-form-radio *").css("fontSize", "22px");
    }
    window.parent.autoIframeHeight();
  }
  layui.use("form", function () {
    // 当前数据
    var laytpl = layui.laytpl;
    var form = layui.form;

    var currentSubject = window.parent.getCurrentSubject();

    var getTpl = demo.innerHTML,
      view = document.getElementById("view");
    laytpl(getTpl).render(currentSubject, function (html) {
      view.innerHTML = html;
    });
    //提交
    form.render();
    form.on("radio(current)", function (data) {
      window.parent.changeData(data.value);
    });
    form.val("form", {
      current: window.parent.getCurrentAnswer(),
    });
    changeSize(currentSubject.size);
  });
</script>

</html>